package cn.bmbanjia.zebra2024.comWechat;

import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class SendMessageUtil {

    public static final String URL_KEFU = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=dff4e702-ee96-41b3-a7ba-98738af3c8ef";
    public static final String URL_CLEW = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=651e23ba-a5d0-422c-9305-ed8d1ea89d32";

    public static final String[] USERS_KEFU = new String[]{"bmbj001"};

    /**
     * @param content 发送内容
     * @param url     群聊url webhook
     * @param users   @的用户id集合
     */
    public static void send(String content, String url, String... users) {
        String param = JSONUtil.createObj()
                .set("msgtype", "text")
                .set("text", JSONUtil.createObj()
                        .set("content", content)
                        .set("mentioned_list", users)).toString();
//        System.out.println("req = " + param);
        String resp = HttpUtil.post(url, param);
        log.info("SendMessageUtil resp = {}", resp);
//        System.out.println("resp = " + resp);
    }

//    public static void main(String[] args) {
//        send("小哥_" + clew.getCreateUserName() + "_提交了新搬家线索", SendMessageUtil.URL_KEFU, SendMessageUtil.USERS_KEFU);
//        send("测试内容 ------------- ", URL_KEFU, USERS_KEFU);
//    }

}
